package com.enhe.gck.com.oracle;

import com.enhe.gck.CarbonRelationType;
import com.enhe.gck.fg.CustomerHWANE16644BNB;
import com.enhe.gck.pojo.Recharge;
import com.kuangkie.carbon.panel.CarbonPanel;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("/oracle" )
public class OracleController {

    @Resource
    private OracleService commOracle;
    @Resource
    private CustomerHWANE16644BNB customerHWANE16644BNB;


    /**
     * test
     */
    @PostMapping("/test/{id}" )
    public Object test(@PathVariable String id) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return customerHWANE16644BNB.getRechargeCount(id,CarbonRelationType.RR_订单记录_散户_客户管理);
    }
    @PostMapping("/test" )
    public void test(@RequestBody List<Recharge> list) {
        customerHWANE16644BNB.test(list);
    }

    /**
     * 获取客户
     */
    @PostMapping("/getyCompan" )
    public boolean getyCompan(@RequestBody OracleEntity.Parameter info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.getCompany(info);
    }

    /**
     * 供应商
     */
    @PostMapping("/getSupplier" )
    public boolean getSupplier(@RequestBody OracleEntity.Parameter info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.getSupplier(info);
    }

    /**
     * 物料
     */
    @PostMapping("/geMaterial" )
    public boolean geMaterial(@RequestBody OracleEntity.Parameter info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.geMaterial(info);
    }
    /**
     * 添加销售发货
     */
    @PostMapping("/saveOrder" )
    public boolean saveOrder(@RequestBody List<OracleEntity.Order> info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.saveOrder(info,true,true);
    }
    @PostMapping("/saveOrderNoSync" )
    public boolean saveOrderNoSync(@RequestBody List<OracleEntity.Order> info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.saveOrder(info,true,false);
    }

    @PostMapping("/deleteOrder" )
    public boolean deleteOrder(@RequestBody OracleEntity.DeleteOrder info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.deleteOrder(info,true);
    }

    /**
     * 充值信息
     */
    @PostMapping("/saveRecharge" )
    public boolean saveRecharge(@RequestBody List<OracleEntity.Recharge> list) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.saveRecharge(list,true);
    }

    /**
     * 提货点接口
     */
    @PostMapping("/savePickup" )
    public boolean savePickup(@RequestBody List<OracleEntity.Pickup> list) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.savePickup(list,true);
    }

    @PostMapping("/getRate" )
    public BigDecimal getRate(@RequestBody OracleEntity.Parameter info) {
        CarbonPanel.changeCurrentProgram(Long.valueOf(LwdHttpConfig.programCode));
        return commOracle.getRate(info);
    }
}
